<template>
  <div>
    <div style="display:flex;flex-direction:row-reverse;margin-top:10px">
      <el-button :disabled="submitLoading" size="mini" type="primary" @click="submitForm(0)">保存</el-button>
      <el-button style="margin-right:20px" :disabled="submitLoading" size="mini" type="primary" @click="submitForm(1)">提交</el-button>
    </div>
    <div v-loading="dataLoading">
      <base-info :base-info="detailData" />
      <!-- <drawing-info :base-info="detailData" /> -->
      <distribute :base-info="detailData" />
      <config-info :base-info="detailData" />
      <studio-confirm :base-info="detailData" />
      <config-info :config-type="1" :base-info="detailData" />
      <!-- 转化分配 -->
      <trans-distribute :base-info="detailData" />
      <!-- 图纸转化信息 -->
      <drawing-trans :base-info="detailData" />
    </div>
    <div style="margin-top:20px" class="qup-title-box"><span class="border" /><span>确图信息</span></div>

    <el-form
      ref="refForm"
      :rules="formRules"
      :model="formData"
      size="mini"
      label-width="150px"
    >
      <el-row>
        <el-col :span="16">
          <el-form-item label="确图备注:" prop="confirmRemark">
            <el-input v-model="formData.confirmRemark" type="textarea" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="复尺确认时间:" prop="rulerConfirmTime">
            <el-date-picker
              v-model="formData.rulerConfirmTime"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              type="datetime"
              disabled
              placeholder="选择日期"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="16">
          <el-form-item label="复尺确认备注:" prop="rulerConfirmRemark">
            <el-input v-model="formData.rulerConfirmRemark" disabled type="textarea" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否可解锁:" prop="isLock">
            <el-radio-group v-model="formData.isLock" disabled>
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import BackPageMixin from '@/mixins/backPage'
import { queryDetail, submitConfirmDrawing } from '@/api/autoDesignTask'
import baseInfo from './component/BaseInfo.vue'
import drawingInfo from './component/DrawingInfo.vue'
import distribute from './component/distributeInfo.vue'
import configInfo from './component/ConfigInfo.vue'
import studioConfirm from './component/StudioConfirm'
import transDistribute from './component/TransDistribute'
import drawingTrans from './component/DrawingTransInfo'
import { nowTime } from '@/utils/tool'

export default {
  name: 'ConfirmDrawing',
  components: { baseInfo, drawingInfo, distribute, configInfo, studioConfirm, transDistribute, drawingTrans },
  mixins: [BackPageMixin],
  props: {
  },
  data() {
    return {
      id: '',
      nowTime,
      detailData: {},
      people: [],
      tableSelected: [],
      submitLoading: false,
      saveLoading: false,
      dataLoading: false,
      formData: {
        id: '',
        confirmRemark: '',
        rulerConfirmTime: '',
        rulerConfirmRemark: '',
        isLock: undefined
      },
      formRules: { }
    }
  },
  watch: {
  },
  async  created() {
    this.id = this.$route.query.id
    if (this.id) {
      this.dataLoading = true
      queryDetail(this.id).then(res => {
        if (res.success) {
          this.detailData = res.data
          const { id, confirmRemark, rulerConfirmTime, rulerConfirmRemark, isLock = undefined } = res.data
          this.formData = { id, confirmRemark, rulerConfirmTime, rulerConfirmRemark, isLock }
          this.dataLoading = false
        }
      })
    }
    this.dataLoading = false
  },
  mounted() {
  },
  methods: {
    goBack() {
      this.$store.dispatch('views/goBack')
    },
    submitForm(type) {
      if (this.submitLoading) return
      this.submitLoading = true
      submitConfirmDrawing(this.formData, type).then(res => {
        if (res.success) {
          this.submitLoading = false
          this.$message.success('操作成功')
          this.goBack()
        }
      }).catch(() => {
        this.submitLoading = false
      })
    }

  }
}
</script>
<style lang="scss" scoped>
/deep/ .el-breadcrumb__inner{
    color: $qup-color-primary;
  }
</style>
